package leetcode;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;

public class ten {
    public static int lengthOfLongestSubstring(String s) {
        if(s==null||s.length()==0){
            return -1;
        }
        List<Integer> list=new ArrayList<>();
        for(int i=0;i<s.length();i++){
            HashSet<Character> set=new HashSet<>();
            for(int j=i;j<s.length();j++){
                char c=s.charAt(j);
                if(!set.contains(c)){
                    set.add(c);
                }else{
                    list.add(j-i);
                    break;
                }
            }
        }
        return Collections.max(list);

    }

    public static void main(String[] args) {
        String string="deabcabca";
        int i = lengthOfLongestSubstring(string);
        System.out.println(i);
    }
}
